//导入axios模块
import axios from 'axios'
import NProgress from "nprogress"
// import "nprogress/nprogress.css"
//使用es6模块语法导出
export function http(config) {
  //创建一个服务器对象/实例
  let instance = axios.create({
    baseURL:'https://localhost:442/api/private/v1/',
  });
  //配置请求拦截器，用于增强和拦截请求
  instance.interceptors.request.use((config)=>{
    NProgress.start();
    config.headers.authorization = window.sessionStorage.getItem('token');
    return config;
  });
  instance.interceptors.response.use((config)=>{
    NProgress.done();
    return config;
  });
  //返回promise对象
  return instance(config);
}